<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>js放大缩小动画</title>
</head>
<body>
	<input type="button" value="开始" id="start">
	<input type="button" value="停止" id="stop">
	<div id="box">
		
	</div>
	
	<style type="text/css">
	#box{
		width: 200px;
		height: 200px;
		border-radius: 50%;
		background: #272822;

	}
	</style>

	<script type="text/javascript">
		function getStyle(obj, attr) 
			{ 
				if(obj.currentStyle){ 
					return obj.currentStyle[attr]; 
				}else{ 
					return getComputedStyle(obj,false)[attr]; 
				} 
			}
		var box=document.getElementById('box');
		var start=document.getElementById('start');
		var stop=document.getElementById('stop');
			var n=1;
			var run =function(){
				width=parseInt(getStyle(box,'width' ));
				height=parseInt(getStyle(box, 'height'));

				if (width=='400') {
					n=0;
				}else if (width=='200'){
					n=1;
				}
				if (n=1) {
					width+=5;
					height+=5;

				}else{
					width-=5;
					height-=5;
				};
				box.style.width=width+'px';
				box.style.height=height+'px';


			}
			time=0;
			start.onclick=function(){
				if (!time) {
					time=setInterval(run, 10)
				};
			}
			stop.onclick=function(){
				clearInterval(time);
				time=0;
			}




	</script>
	
</body>
</html>